Skip to content

Fix "False positive staticMethod.alreadyNarrowedType for Strings::length() inside numeric comparison"#210

Merged
staabm merged 13 commits into
phpstan:2.0.xfrom
staabm:fix
Jul 2, 2026
Merged

Fix "False positive staticMethod.alreadyNarrowedType for Strings::length() inside numeric comparison"#210
staabm merged 13 commits into
phpstan:2.0.xfrom
staabm:fix

Conversation

@staabm

@staabm staabm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

closes #209

Comment thread .github/workflows/e2e-tests.yml Fixed
Comment thread .github/workflows/e2e-tests.yml Fixed
Comment thread .github/workflows/e2e-tests.yml Fixed
Comment on lines +38 to +39
- name: "Checkout"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
directory: "e2e"

- name: "Test"
run: ${{ matrix.script }}
Comment thread .github/workflows/e2e-tests.yml Fixed
Comment thread .github/workflows/e2e-tests.yml Fixed
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: "Install PHP"
uses: "shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc" # v2.37.1
coverage: "none"
php-version: "8.2"

- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0
- uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0

- name: "Install bashunit"
uses: "TypedDevs/bashunit@ffa9c79e71ecbb9990e777348bc9ba12314b62d0" # 0.39.1
Comment on lines +27 to +31
include:
- script: |
cd e2e/bug-208
composer install
vendor/bin/phpstan

@staabm staabm Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a e2e suite, based on phpstan-src.

it was needed because the error beeing fixed is issued by a phpstan-core rule and it only happens with type inference extensions of phpstan-nette

the added tests reproduced the origin problem in https://github.com/phpstan/phpstan-nette/actions/runs/28579140883/job/84734877032?pr=210

@staabm staabm marked this pull request as ready for review July 2, 2026 09:20
@staabm staabm requested a review from VincentLanglet July 2, 2026 09:20
@staabm staabm merged commit 2c104f1 into phpstan:2.0.x Jul 2, 2026
45 checks passed
@staabm

staabm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

will tag a new release after lunch break

@staabm staabm deleted the fix branch July 2, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive staticMethod.alreadyNarrowedType for Strings::length() inside numeric comparison

3 participants